﻿#if USE_UNI_LUA
using LuaAPI = UniLua.Lua;
using RealStatePtr = UniLua.ILuaState;
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
#else
using LuaAPI = XLua.LuaDLL.Lua;
using RealStatePtr = System.IntPtr;
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
#endif

using XLua;
using System.Collections.Generic;


namespace XLua.CSObjectWrap
{
    using Utils = XLua.Utils;
    public class SimpleNetWrap 
    {
        public static void __Register(RealStatePtr L)
        {
			ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			System.Type type = typeof(SimpleNet);
			Utils.BeginObjectRegister(type, L, translator, 0, 3, 2, 2);
			
			Utils.RegisterFunc(L, Utils.METHOD_IDX, "Start", _m_Start);
			Utils.RegisterFunc(L, Utils.METHOD_IDX, "Update", _m_Update);
			Utils.RegisterFunc(L, Utils.METHOD_IDX, "Destroy", _m_Destroy);
			
			
			Utils.RegisterFunc(L, Utils.GETTER_IDX, "NetManager", _g_get_NetManager);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "NetPacketProcessor", _g_get_NetPacketProcessor);
            
			Utils.RegisterFunc(L, Utils.SETTER_IDX, "NetManager", _s_set_NetManager);
            Utils.RegisterFunc(L, Utils.SETTER_IDX, "NetPacketProcessor", _s_set_NetPacketProcessor);
            
			
			Utils.EndObjectRegister(type, L, translator, null, null,
			    null, null, null);

		    Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
			
			
            
			
			
			
			Utils.EndClassRegister(type, L, translator);
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __CreateInstance(RealStatePtr L)
        {
            
			try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
				if(LuaAPI.lua_gettop(L) == 1)
				{
					
					var gen_ret = new SimpleNet();
					translator.Push(L, gen_ret);
                    
					return 1;
				}
				
			}
			catch(System.Exception gen_e) {
				return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
			}
            return LuaAPI.luaL_error(L, "invalid arguments to SimpleNet constructor!");
            
        }
        
		
        
		
        
        
        
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Start(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
            
            
			    int gen_param_count = LuaAPI.lua_gettop(L);
            
                if(gen_param_count == 7&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<LiteNetLib.EventBasedNetListener>(L, 3)&& translator.Assignable<LiteNetLib.Utils.NetPacketProcessor>(L, 4)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 6)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 7)) 
                {
                    int _port = LuaAPI.xlua_tointeger(L, 2);
                    LiteNetLib.EventBasedNetListener _listener = (LiteNetLib.EventBasedNetListener)translator.GetObject(L, 3, typeof(LiteNetLib.EventBasedNetListener));
                    LiteNetLib.Utils.NetPacketProcessor _processor = (LiteNetLib.Utils.NetPacketProcessor)translator.GetObject(L, 4, typeof(LiteNetLib.Utils.NetPacketProcessor));
                    bool _broadcastReceiveEnabled = LuaAPI.lua_toboolean(L, 5);
                    bool _unconnectedMessagesEnabled = LuaAPI.lua_toboolean(L, 6);
                    int _updateTime = LuaAPI.xlua_tointeger(L, 7);
                    
                        var gen_ret = gen_to_be_invoked.Start( _port, _listener, _processor, _broadcastReceiveEnabled, _unconnectedMessagesEnabled, _updateTime );
                        LuaAPI.lua_pushboolean(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                if(gen_param_count == 6&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<LiteNetLib.EventBasedNetListener>(L, 3)&& translator.Assignable<LiteNetLib.Utils.NetPacketProcessor>(L, 4)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 6)) 
                {
                    int _port = LuaAPI.xlua_tointeger(L, 2);
                    LiteNetLib.EventBasedNetListener _listener = (LiteNetLib.EventBasedNetListener)translator.GetObject(L, 3, typeof(LiteNetLib.EventBasedNetListener));
                    LiteNetLib.Utils.NetPacketProcessor _processor = (LiteNetLib.Utils.NetPacketProcessor)translator.GetObject(L, 4, typeof(LiteNetLib.Utils.NetPacketProcessor));
                    bool _broadcastReceiveEnabled = LuaAPI.lua_toboolean(L, 5);
                    bool _unconnectedMessagesEnabled = LuaAPI.lua_toboolean(L, 6);
                    
                        var gen_ret = gen_to_be_invoked.Start( _port, _listener, _processor, _broadcastReceiveEnabled, _unconnectedMessagesEnabled );
                        LuaAPI.lua_pushboolean(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                if(gen_param_count == 5&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<LiteNetLib.EventBasedNetListener>(L, 3)&& translator.Assignable<LiteNetLib.Utils.NetPacketProcessor>(L, 4)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5)) 
                {
                    int _port = LuaAPI.xlua_tointeger(L, 2);
                    LiteNetLib.EventBasedNetListener _listener = (LiteNetLib.EventBasedNetListener)translator.GetObject(L, 3, typeof(LiteNetLib.EventBasedNetListener));
                    LiteNetLib.Utils.NetPacketProcessor _processor = (LiteNetLib.Utils.NetPacketProcessor)translator.GetObject(L, 4, typeof(LiteNetLib.Utils.NetPacketProcessor));
                    bool _broadcastReceiveEnabled = LuaAPI.lua_toboolean(L, 5);
                    
                        var gen_ret = gen_to_be_invoked.Start( _port, _listener, _processor, _broadcastReceiveEnabled );
                        LuaAPI.lua_pushboolean(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                if(gen_param_count == 4&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<LiteNetLib.EventBasedNetListener>(L, 3)&& translator.Assignable<LiteNetLib.Utils.NetPacketProcessor>(L, 4)) 
                {
                    int _port = LuaAPI.xlua_tointeger(L, 2);
                    LiteNetLib.EventBasedNetListener _listener = (LiteNetLib.EventBasedNetListener)translator.GetObject(L, 3, typeof(LiteNetLib.EventBasedNetListener));
                    LiteNetLib.Utils.NetPacketProcessor _processor = (LiteNetLib.Utils.NetPacketProcessor)translator.GetObject(L, 4, typeof(LiteNetLib.Utils.NetPacketProcessor));
                    
                        var gen_ret = gen_to_be_invoked.Start( _port, _listener, _processor );
                        LuaAPI.lua_pushboolean(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
            return LuaAPI.luaL_error(L, "invalid arguments to SimpleNet.Start!");
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Update(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
            
            
                
                {
                    
                    gen_to_be_invoked.Update(  );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Destroy(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
            
            
                
                {
                    
                    gen_to_be_invoked.Destroy(  );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        
        
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_NetManager(RealStatePtr L)
        {
		    try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.NetManager);
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_NetPacketProcessor(RealStatePtr L)
        {
		    try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.NetPacketProcessor);
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }
        
        
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_NetManager(RealStatePtr L)
        {
		    try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.NetManager = (LiteNetLib.NetManager)translator.GetObject(L, 2, typeof(LiteNetLib.NetManager));
            
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_NetPacketProcessor(RealStatePtr L)
        {
		    try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			
                SimpleNet gen_to_be_invoked = (SimpleNet)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.NetPacketProcessor = (LiteNetLib.Utils.NetPacketProcessor)translator.GetObject(L, 2, typeof(LiteNetLib.Utils.NetPacketProcessor));
            
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }
        
		
		
		
		
    }
}
